<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
<title>修改字段</title>
<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
<link rel="stylesheet" href="../static/web/css/admin.css">
<script language="javascript" src="../static/web/js/jquery.min.js"></script>
<script src="../static/web/js/bootstrap.bundle.min.js"></script>
<script language='javascript' src="js/main.js"></script>
<script language="javascript">
function GetFields()
{
	var theform = document.form1;
	var itemname = theform.itemname.value;
	var fieldname = theform.fname.value;
	var dtype = theform.dtype.value;
	var isnull = theform.isnull.value;
	var vdefault = theform.vdefault.value;
	var maxlength = theform.maxlength.value;
	var vinnertext = theform.vinnertext.value;
	var spage = (theform.spage[0].checked ? theform.spage[0].value : theform.spage[1].value);
	var sisnull = (isnull==0 ? "false" : "true");
	if(itemname=="")
	{
		ShowMsg("表单提示名称不能为空");
		theform.itemname.focus();
		return false;
	}
	if((dtype=="radio"||dtype=="select"||dtype=="checkbox") && vdefault=="")
	{
		ShowMsg("您选择的select或radio、checkbox类型，必须默认值设置选择的项目（用逗号[,]分开）");
		return false;
	}
	if(spage=="no") spage = "";
	revalue =  "<field:"+fieldname+" itemname=\""+itemname+"\" autofield=\"1\" type=\""+dtype+"\"";
	revalue += " isnull=\""+sisnull+"\" default=\""+vdefault+"\" ";
	revalue += " maxlength=\""+maxlength+"\" page=\""+spage+"\">"+vinnertext+"</field:"+fieldname+">";
	document.form1.fieldstring.value = revalue;
  return true;
  
}
</script>
<style>
td{ padding:6px; padding-left:6px; }
.style1 {color: #FF3300}
.style2 {color: #424b51}
.nw { float:left; width:150px; }
.cls { clear:both; }
</style>
</head>
<body>
<table width="98%" cellpadding="1" cellspacing="1" align="center" class="table maintable mt-3 mb-3">
  <form name="form1" action="diy_field_edit.php" method="post" onSubmit="return GetFields();">
  	<input type='hidden' name='action' value='save'>
  	<input type='hidden' name='diyid' value='<?php echo $diyid?>'>
  	<input type='hidden' name='fname' value='<?php echo $fname?>'>
	  <input type='hidden' name='issystem' value='<?php echo $issystem?>'>
	  <input type='hidden' name='fieldstring' value=''>
    <tr> 
      <td height="26" colspan="2" background="../static/web/img/tbg.gif">
        <table width="98%" cellspacing="0" cellpadding="0" class="table table-borderless">
          <tr> 
            <td width="30%" style="padding-left:10px"><a href="diy_main.php">自定义表单管理</a> &gt; 修改字段</td>
            <td align="right">
			        <button type="button" name="ss1" onClick="location='diy_edit.php?diyid=<?php echo $diyid; ?>&dopost=edit';" class="btn btn-success btn-sm">当前表单信息</button>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    <tr> 
      <td>表单提示文字：<br>
        <span class="style2">发布内容时显示的提示文字</span>
      </td>
      <td><input name="itemname" type="text" id="itemname" value="<?php echo $ctag->GetAtt('itemname')?>" class="pubinputs"> *（发布内容时显示的项名字）</td>
    </tr>
    <tr> 
      <td width="28%">字段名称：<br>
        <span class="style2">只能用英文字母或数字，数据表的真实字段名</span>
      </td>
      <td width="72%" style="table-layout:fixed;word-break:break-all"><?php echo $fname?></td>
    </tr>
    <tr> 
      <td>数据类型：</td>
      <td>
      	<select name="dtype" id="type" style="width:260px">
          <?php 
          $dtype = $ctag->GetAtt('type');
          if($dtype!='' && isset($fieldtypes[$dtype]))
          {
          	echo "<option value='{$dtype}'>{$fieldtypes[$dtype]}</option>";
          	$canchange = true;
          } else {
          	echo "<option value='{$dtype}'>系统专用类型</option>";
          	$canchange = false;
          }
          if($canchange)
          {
          ?>
          <option value="text">单行文本(varchar)</option>
          <option value="textchar">单行文本(char)</option>
          <option value="multitext">多行文本</option>
          <option value="htmltext">HTML文本</option>
          <option value="int">整数类型</option>
          <option value="float">小数类型</option>
          <option value="datetime">时间类型</option>
          <option value="img">图片</option>
          <option value="addon">附件类型</option>
          <option value="select">使用option下拉框</option>
          <option value="radio">使用radio选项卡</option>
          <option value="checkbox">Checkbox多选框</option>
          <?php
           }
          ?>
        </select>
      </td>
    </tr>
    <tr> 
      <td>内容是否需要分页符：<br>
        <span class="style2">如果内容需要分页符，不论何种内容，都可以用#P#副标题#e#作为分页符号实现内容分页，但一个模型里仅允许一个这样的字段!</span></td>
      <td>
      	<input name="isnull" type="hidden" value="1">
        <label><input name="spage" type="radio"  value="split"<?php if($ctag->GetAtt('page')=='split') echo " checked='1' "; ?> class='np'>
        是 &nbsp; </label>
        <label><input name="spage" type="radio"  value="no"<?php if($ctag->GetAtt('page')=='no'||$ctag->GetAtt('page')=='') echo " checked='1' "; ?> class='np'>
        否</label></td>
      </tr>
    <tr> 
      <td>默认值：<br>
        <span class="style2"> 如果定义数据类型为select、radio、checkbox时，此处填写被选择的项目(用“,”分开，如“男,女,人妖”)，如果为联动选框，这里填写联动选框项目名称</span></td>
      <td><textarea name="vdefault" type="text" id="vdefault" style="width:70%;height:60px"><?php echo $ctag->GetAtt('default'); ?></textarea></td>
    </tr>
    <tr> 
      <td>最大长度：<br>
        <span class="style2"> 文本数据必须填写，大于255为text类型 </span></td>
      <td>
      	<input name="maxlength" type="text" id="maxlength" value="<?php echo $ctag->GetAtt('maxlength')?>" style="width:80px;padding-top:3px;"></td>
    </tr>
    <tr>
      <td style="padding-left:10px">自定义表单HTML：</td>
      <td>
      	自定义表单HTML用~name~表示提示文字，~form~表示表单元素<br>      </td>
    </tr>
    <tr> 
      <td align="center"><br>      </td>
      <td><textarea name="vinnertext" cols="45" rows="5" id="vinnertext" style="width:70%;height:120px"><?php echo $ctag->GetInnerText(); ?></textarea></td>
    </tr>
    <tr>
      <td height="26" colspan="2" bgcolor="#f8f8f8">
        <table width="100%" cellspacing="0" cellpadding="0" class="table table-borderless mb-3">
          <tr>
            <td align="center" class="py-3">
              <button type="submit" class="btn btn-success btn-sm">保存</button>
              <button type="reset" class="btn btn-success btn-sm">重置</button>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </form>
</table>
</body>
</html>